package com.dayuan.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dayuan.bean.Goods;
import com.dayuan.dao.GoodsMapper;

@Service
public class SellerGoodsService {

	@Resource
	private GoodsMapper goodsMapper;

	/**
	 * 商家查询商品，支持商品名模糊查询、商品id查询、查询所有
	 * 
	 * @param good
	 * @return
	 */
	public List<Goods> sellerSelectGoods(Goods goods, Integer startIndex, Integer pageNum) {
		List<Goods> goodsList = goodsMapper.selectSellerGoods(goods, startIndex, pageNum);
		return goodsList;
	}

	/**
	 * 查询分页总行数
	 * 
	 * @param goods
	 * @return
	 */
	public int selcetTotal(Goods goods) {
		int tatol = goodsMapper.total(goods);
		return tatol;
	}
	/**
	 * 删除商品
	 * @param goods
	 * @return
	 */
	public int deletegoodById(Long id,Integer merchantId){
		return  goodsMapper.deletegoodById(id,merchantId);
	}
	/**
	 * 更新商品
	 * @param goods
	 * @return
	 */
	public int updateGoods(Goods goods){
		return  goodsMapper.updateGoodsByParams(goods);
	}
	/**
	 * 增加商品
	 * @param goods
	 * @return
	 */
	public int insertGoodsSelective(Goods goods){
		return  goodsMapper.insertGoodsSelective(goods);
	}
}
